package spotGUI.mainFrameGUI;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.HashMap;

import javax.swing.JPanel;
import javax.swing.JSplitPane;

import spotGUI.ElementViewer.ElementPanel;
import utils.SocialUserData;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;



public class SocialNetworkMainPanel extends JPanel {
	
	private JSplitPane splitPane;
	private SocialNetworkSideBar socialNetworkSideBar;
	private ElementPanel elementPanel;

	
	public SocialNetworkMainPanel() {
		addComponentListener(new ComponentAdapter() {
			@Override
			public void componentShown(ComponentEvent arg0) {
				updateElements();
			}
		});
		
		GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0};
		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{1.0, Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		splitPane = new JSplitPane();
		splitPane.setResizeWeight(0.2);
		GridBagConstraints gbc_splitPane_1 = new GridBagConstraints();
		gbc_splitPane_1.fill = GridBagConstraints.BOTH;
		gbc_splitPane_1.gridx = 0;
		gbc_splitPane_1.gridy = 0;
		add(splitPane, gbc_splitPane_1);
		
		socialNetworkSideBar = new SocialNetworkSideBar();
		splitPane.setLeftComponent(socialNetworkSideBar);
		
		elementPanel = new ElementPanel();
		splitPane.setRightComponent(elementPanel);
	}


	public void fillSidebar(HashMap<Integer, SocialUserData> socialUsersData) {
		socialNetworkSideBar.fillSidebar(socialUsersData);
		
	}

	
	public void updateElements () {
		elementPanel.update();
	}
	


}
